#ifndef _Primitive_H_
#define _Primitive_H_

#pragma once
#include "LightingRender.h"
#include "Ray.h"
#include "Normal3.h"
#include "Material.h"
#include "IntersectResult.h"

class Primitive : protected enable_shared_from_this<Primitive> {
protected:
	shared_ptr<Material> material;

public:
	Primitive() {}
	virtual ~Primitive() {}

	virtual bool intersect(const Ray &ray, IntersectResult &result) const = 0;
	virtual bool intersectP(const Ray &ray) const = 0;

	inline static string getName() {
		return string("primitive");
	}
	virtual string str() const = 0;
	shared_ptr<Primitive> setMaterial(shared_ptr<Material> material) {
		this->material = material;
		return shared_from_this();
	}
	const shared_ptr<Material> & getMaterial() const {
		return material;
	}
};

#endif // _Primitive_H_